/**
 * Created by LuoQuan on 2017/11/7.
 */

Ext.define('Cms.website.view.Login', {
    extend: 'Ext.window.Window',
    xtype: 'Login',

    resizable: false,
    closable: false,
    autoShow: true,
    closeAction: 'destroy',
    title: '登录',
    titleAlign: 'center',

    icon: '/resources/icon/ajia.ico',
    iconCls: 'icon',

    layout: {
        type: 'fit'
    },

    //屏蔽Esc按键
    onEsc: function () {
        return true;
    },

    requires: [
        'Cms.website.controller.Login',
        'Cms.website.model.login.loginModel'
    ],

    controller: 'login',
    viewModel: 'login',

    items: [{
        xtype: 'form',
        bodyPadding: 15,
        defaults: {
            xtype: 'textfield',
            anchor: '100%',
            labelWidth: 45
        },
        layout: {
            type: 'vbox',
            align: 'center'
        },
        items: [{
            name: 'user',
            fieldLabel: '登录名',
            allowBlank: false,
            blankText: '登录名不能为空'
        }, {
            name: 'pwd',
            fieldLabel: '密&nbsp;&nbsp;&nbsp;码',
            allowBlank: false,
            blankText: '密码不能为空'
        }, {
            xtype: 'combo',
            name: 'role',
            editable: false,
            fieldLabel: '角&nbsp;&nbsp;&nbsp;色',
            displayField: 'value',
            valueField: 'key',
            value: 'contentMgr',
            store: Ext.create('Ext.data.Store', {
                fields: ['key', 'value'],
                data: [
                    {key: 'contentMgr', value: '内容负责人'},
                    {key: 'teacher', value: '内容老师'},
                    {key: 'manager', value: '管理员'}
                ]
            })
        }, {
            xtype: 'component',
            width: 220,
            height: 64,
            margin: '0 0 15 0',
            style: 'background-color:#eee;cursor:pointer;',
            autoEl: {
                tag: 'canvas',
                title: '看不清？点击画布更新验证码'
            },
            listeners: {
                render: 'initCanvas'
            }
        }, {
            reference: 'inputcode',
            fieldLabel: '验证码',
            allowBlank: false,
            emptyText: '请输入验证码',
            blankText: '验证码不能为空'
        }],
        buttons: ['->', {
            text: '重置',
            handler: 'reset'
        }, '-', {
            text: '登录',
            handler: 'login'
        }, '->']
    }]
});